package com.skz;

import cn.zhouyafeng.itchat4j.Wechat;
import com.skz.handler.AbstractIMsgHandlerFace;
import com.skz.util.RedisKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author: 宋开宗
 * @create: 2019-03-30 14:10
 **/
@Component
public class DataInit implements CommandLineRunner {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Value("${qrPath}")
    private String qrPath;

    @Override
    public void run(String... args) {
        stringRedisTemplate.opsForHash().entries(RedisKey.GROUPS)
                .forEach((o, o2) -> stringRedisTemplate.opsForHash().put(RedisKey.GROUPS, o.toString(), "已失效"));
        Wechat wechat = new Wechat(new AbstractIMsgHandlerFace() {

        }, qrPath);
        wechat.start();
    }
}
